grammar IEEE_1450_Std_2002_2023;
import STIL_Lexer;
//options{tokenVocab = STIL_Lecer;}
//ANTLR词法分析器通过偏爱首先指定的规则来解决词法规则间的二义性
//这意味着范围大的规则应该定义在所有的关键词规则之后。ANTLR把隐式的为
//字面量生成的词法规则放在显式的词法规则之前，因此它们总是有更高的优先级。

//This STIL syntax paser only support 《IEEE Std 1450 - 2002》 and 《IEEE 1450 Std - 2023》.

//================================STIL Structure=========================================//
//Only one Header Block and global Signals are allowed per STIL file.
ieee_std_1450_2002_2023   : stil header? stil_block;

stil_block      : user_keywords     stil_block    //new
                | user_functions    stil_block    //new
                | signals           stil_block
                | signal_groups     stil_block
                | dc_levels         stil_block
                | dc_sets           stil_block

                | timing            stil_block
                | spec              stil_block
                | selector          stil_block
                | scan_structure    stil_block
                | procedures        stil_block    //new
                | macrodefs         stil_block    //new
                | pattern           stil_block   //new

                | pattern_burst     stil_block
                | pattern_exec      stil_block
                | include           stil_block
                | annotation        stil_block

//                | udb               stil_block
                |    //new
                ;

//udb             : WORDS ('{' .*? '}')|(~('{'|'}'|';'));
//================================STIL BLOCK=========================================//
stil    :   'STIL' stil_version_number
            (('{' (extend ';')+ '}')
        |   (';'))
        ;
extend                  : ext_name extend
                        | ext_version extend
                        |
                        ;
ext_name                :   'DCLevels';
ext_version             :   '2002';
stil_version_number     :   FLOAT;

////================================Header BLOCK=========================================//
header          :   'Header' '{'  header_item  '}';
header_string   : NAME_STRING|STRING;
header_item     : ('Title'   header_string ';')         header_item
                | ('Date'     header_string ';')        header_item
                | ('Source'   header_string ';')        header_item
                | ('History' '{' annotation* '}')       header_item
                | (include)                             header_item
                | annotation                            header_item
                |
                ;

//================================Ann BLOCK=========================================//
annotation      : ('Ann' ANN_TEXT);

//================================include Statement=========================================//
include         : ('Include'  STRING  ('IfNeed' blocktype)? ';');
blocktype       : 'Include'|'Header'|'UserKeywords'|'UserFunctions'|'Signals'|'SignalGroups'
                | 'PatternExec'|'PatternBurst'|'Timing'|'Spec'
                | 'DCLevels'| 'DCSets'| //《IEEE Std 1450 - 2002》
                | 'Selector'
                | 'ScanStructures'
                | 'Pattern'|'Procedures'|'MacroDefs'|'Ann';

//================================UserKeywords Statement=========================================//
user_keywords   : 'UserKeywords' user_defined_keywords+ ';';
user_defined_keywords : WORDS;


//================================UserFunctions Statement=========================================//
user_functions  : 'UserFunctions' user_defined_function+ ';';
user_defined_function : WORDS;

//================================Signals BLOCK=========================================//
signals         : 'Signals' '{'  signals_list?  '}';
signals_list    : ((signal_name signal_type ';')
                |  (signal_name signal_type '{' (sig_statement|free_running_clock)? '}')
//                | include
//                | annotation
//                | udb
                  )*
                ;
signal_name     : WORDS (('[' integer ']')|('[' integer '.' '.' integer ']'))?;
signal_type     : 'In'|'Out'|'InOut'|'Supply'|'Pseudo';
sig_statement   :  terminations                     sig_statement       //可调用0次或一次
                |  (default_state_stmt)             sig_statement       //可调用0次或一次
                |  ('Base' base_type ';')           sig_statement       //可调用0次或一次
                |  ('Alignment' orient_type ';')    sig_statement       //可调用0次或一次
                |  ('ScanIn'  integer? ';')         sig_statement       //可调用0次或一次
                |  ('ScanOut'  integer?  ';')       sig_statement       //可调用0次或一次
                |  ('ScanClock' ';')                sig_statement       //可调用0次或一次
                |  ('DataBitCount' integer ';')     sig_statement       //可调用0次或一次
                |
                  //| include | annotation | udb |
                ;
free_running_clock      : 'FreeRunningClock' '{' free_running_clock_list '}';//《IEEE 1450 Std - 2023》
free_running_clock_list : 'Period' '\'' time_expr '\'' ';'              free_running_clock_list
                        |  ('LeadingEdge' '\'' time_expr '\'' ';')      free_running_clock_list
                        |  ('TrailingEdge' '\'' time_expr '\'' ';')     free_running_clock_list
                        |  ('OffState'offstate ';' )                    free_running_clock_list
                        |  ('Gated' ';')                                free_running_clock_list
                        |   //需要在函数中对重复的部分进行剔除和报错
                        ;
offstate                : 'U' | 'D' | 'ForceUp' | 'ForceDown';
terminations            : ('Termination' termination_state ';');
termination_state       : 'TerminateHigh' | 'TerminateLow' | 'TerminateOff' | 'TerminateUnknown';
default_state_stmt      : ('DefaultState' default_state ';');
default_state           : 'U' | 'ForceUp' | 'D' | 'ForceDown' | 'Z' | 'ForceOff';
base_type               : ('Hex' wfcs )|('Dec' wfcs);
orient_type             : 'LSB' | 'MSB';
integer                 : DIGIT|INTEGER|digit;

//================================SignalGroups BLOCK=========================================//
signal_groups           : 'SignalGroups' signal_groups_domain_name? '{' (groups_list1|groups_list2)*?  '}';

groups_list1             : (group_name '=' sigref_expr ';');
groups_list2             : (group_name '=' sigref_expr '{' (sig_statement)? '}');

sigref_expr             : ('\'' group_name_exp_list '\'') | signal_or_group_name;
group_name_exp_list     : group_name_exp_list ('+'|'-') group_name_exp_list
                        | '(' group_name_exp_list ')'
                        | signal_or_group_name
                        ;
signal_or_group_name    : group_name|signal_name;
signal_groups_domain_name             : name_string;
group_name                            : WORDS;

//======================================PatternExec Block=========================================//
pattern_exec            : 'PatternExec' pat_exec_name? '{' pat_exec_list_item? '}';
pat_exec_name           : name_string;
pat_exec_list_item      :  ('Category' category_name ';')       pat_exec_list_item  //可调用多次
                        |  ('Selector' selector_name ';')       pat_exec_list_item  //可调用多次
                        |  ('DCLevels' dc_levels_name ';')      pat_exec_list_item  //可调用0次或一次
                        |  ('DCSets' dc_sets_name ';')          pat_exec_list_item  //可调用0次或一次
                        |  ('Timing'   timing_name   ';')       pat_exec_list_item  //可调用0次或一次
                        |  ('PatternBurst' pat_burst_name ';')  pat_exec_list_item  //可调用0次或一次
                        |   //需要在函数中对重复的部分进行剔除和报错
                        //include|annotation|udb|
                        ;

//======================================PatternBurst Block=========================================//
pattern_burst           : 'PatternBurst' pat_burst_name '{' pat_burst_stmnts? '}';
pat_burst_stmnts        : ('SignalGroups' groups_domain        ';')        pat_burst_stmnts
                        | ('MacroDefs'      scan_macros_domain ';')        pat_burst_stmnts
                        | ('Procedures'   procedures_domain    ';')        pat_burst_stmnts
                        | ('ScanStructures' scan_name  ';')                pat_burst_stmnts
                        | ('Start'   pat_label    ';')                     pat_burst_stmnts
                        | ('Stop'   pat_label    ';')                      pat_burst_stmnts
                        | ('Termination'  '{' termination_statements* '}') pat_burst_stmnts
                        | ('PatList' '{' pat_list_item? '}')               pat_burst_stmnts
                        |   //需要在函数中对重复的部分进行剔除和报错
                        //include|annotation|udb|
                        ;

pat_list_item           : (pat_name ';')                                pat_list_item
                        | (pat_name '{' pat_list_stmt? '}')             pat_list_item
                        | (pat_burst_name ';')                          pat_list_item
                        | (pat_burst_name '{' pat_list_stmt? '}')       pat_list_item
                        |
                        ;

pat_list_stmt           : ('SignalGroups' groups_domain ';')                        pat_list_stmt
                        | ('MacroDefs'      scan_macros_domain ';')                 pat_list_stmt
                        | ('Procedures'   procedures_domain    ';')                 pat_list_stmt
                        | ('ScanStructures' scan_name  ';')                         pat_list_stmt
                        | ('Start'   pat_label    ';')                              pat_list_stmt
                        | ('Stop'   pat_label    ';')                               pat_list_stmt
                        | ('Termination' '{' termination_statements* '}')           pat_list_stmt
                        |   //需要在函数中对重复的部分进行剔除和报错
                        //include|annotation|udb|
                        ;
termination_statements  :   (sigref_expr|signal_or_group_name) termination_state ';';
pat_label               : name_string;
groups_domain           : name_string;
scan_macros_domain      : name_string;
procedures_domain       : name_string;
pat_burst_name          : name_string;
//======================================ScanStructures Block=========================================//
scan_structure          : 'ScanStructures' scan_name? '{'  scanchains*  '}';
scanchains              : 'ScanChain' chain_name '{' scan_struct_list?  '}';
scan_struct_list        : 'ScanLength' integer ';'              scan_struct_list
                        | 'ScanOutLength' integer ';'           scan_struct_list
                        | 'ScanCells' cellname_list ';'         scan_struct_list
                        | 'ScanIn' signal_name ';'              scan_struct_list
                        | 'ScanOut' signal_name ';'             scan_struct_list
                        | 'ScanMasterClock' signal_name ';'     scan_struct_list
                        | 'ScanSlaveClock' signal_name ';'      scan_struct_list
                        | 'ScanInversion' bit ';'               scan_struct_list
                        |//| include | annotation | udb | (null)
                        //需要在函数中对重复的部分进行剔除和报错
                        ;
chain_name              : name_string;
scan_name               : name_string;
cellname_list           : name_string      cellname_list
                        | '!' (name_string| ) cellname_list
                        |
                        ;
bit                     : '0' | '1';

//======================================DCLevels and DCSets Block=========================================//
dc_levels               : 'DCLevels' dc_levels_name? '{'  dc_levels_list '}';
dc_levels_list          : 'InheritDCLevels' dc_levels_name ';'  dc_levels_list
                        | 'SignalGroups' signal_groups_domain_name ';' dc_levels_list
                        | dc_levels_list_item dc_levels_list
                        |
                        ;

dc_levels_list_item     : sigref_expr '{' expr* '}';


expr                    : 'VIH'         dc_expr ';'
                        | 'VIL'         dc_expr ';'
                        | 'VICM'        dc_expr ';'
                        | 'VID'         dc_expr ';'
                        | 'VIHD'        dc_expr ';'
                        | 'VILD'        dc_expr ';'
                        | 'ForceHi'             ';'
                        | 'ForceLo'             ';'
                        | 'InitHi'              ';'
                        | 'InitLo'              ';'
                        | 'VIHSlew'     dc_expr ';'
                        | 'VILSlew'     dc_expr ';'
                        |  'VOH'        dc_expr ';'
                        |  'VOL'        dc_expr ';'
                        |  'VOCM'       dc_expr ';'
                        |  'VOD'        dc_expr ';'
                        |  'VOHD'       dc_expr ';'
                        |  'VOLD'       dc_expr ';'
                        |  'IOH'        dc_expr ';'
                        |  'IOL'        dc_expr ';'
                        |  'LoadVRef'   dc_expr ';'
                        |  'ClampHi'    dc_expr ';'
                        |  'ClampLo'    dc_expr ';'
                        |  'ResistiveTermination' dc_expr ';'
                        |  'TermVRef'   dc_expr ';'
                        |  'VForce'     dc_expr ';'
                        |  'IClamp'     dc_expr ';'
                        |  'IForce'     dc_expr ';'
                        |  'VClamp'     dc_expr ';'
                        ;
dc_expr                 : '\'' time_expr+ '\'';


dc_sets                 : 'DCSets' dc_sets_name '{' dc_levels_ref* '}';
dc_levels_ref           : 'DCLevels' dc_levels_name ';' ;

dc_levels_name          : name_string;
dc_sets_name            : name_string;


//======================================Spec and Selector Block=========================================//
spec                    : 'Spec' spec_name? '{'  spec_list?  '}';
spec_name               : name_string;
category_name           : name_string;
selector_name           : name_string;
var_name                : name_string;
spec_list               : 'Category' category_name '{'  var_spec_info?  '}' spec_list
                        | 'Variable' var_name '{'  cat_spec_info?  '}'  spec_list
                        //| include | annotation | udb | (null)
                        |
                        ;
var_spec_info           : var_name '=' '\'' time_expr '\'' ';' var_spec_info
                        | var_name '{' ('Min' '\'' time_expr '\'' ';')? ('Typ' '\'' time_expr '\'' ';')? ('Max' '\'' time_expr '\'' ';')? '}' var_spec_info
                         //| include | annotation | udb | (null)
                        |
                        ;

cat_spec_info           : category_name '\'' time_expr '\'' ';' cat_spec_info
                        | category_name '{' ('Min' '\'' time_expr '\'' ';')? ('Typ' '\'' time_expr '\'' ';')? ('Max' '\'' time_expr '\'' ';')? '}' cat_spec_info
                        //| include | annotation | udb | (null)
                        |
                        ;

selector                : 'Selector' selector_name '{'  selector_list?  '}';
selector_list           : selector_item*;
selector_item           : var_name selector_type ';';
selector_type           : 'Min' | 'Typ' | 'Max' | 'Meas';

//============================Procedures blocks=================================//
procedures              : 'Procedures' procedure_name? '{'  procedure_definitions*  '}';
procedure_definitions   : procedure_name '{'  procedure_or_macro_statements '}'
                        //| include | annotation | udb | (null)
                        ;
procedure_or_macro_statements    : 'Shift' '{' pattern_statements '}' procedure_or_macro_statements
                                 | pattern_statements procedure_or_macro_statements
                                 |
                                 ;
procedure_name          : name_string;

//============================MacroDefs blocks=================================//
macrodefs               : 'MacroDefs'  macro_name?  '{'  macro_definitions*  '}';
macro_definitions       : macro_name '{'  procedure_or_macro_statements  '}'
                        //| include | annotation | udb | (null)
                        ;
macro_name              : name_string;


//======================================Pattern Block=========================================//
pattern                   : 'Pattern' pat_name '{' pattern_statements* '}';
pattern_statements      : waveform_table_stmt wft ';'
                        | 'DCLevels' wft ';'
                        | 'Loop' integer '{'  pattern_statements?  '}'
                        | 'MatchLoop' integer '{' pattern_statements 'BreakPoint' '{' pattern_statements '}' '}'
                        | 'MatchLoop Infinite' '{' pattern_statements 'BreakPoint' '{' pattern_statements '}' '}'
                        | vector_stmt
                        | condition_stmt
                        | 'Call' procedure_name ';'
                        | 'Call' procedure_name '{' vec_data '}'
                        | 'Macro' macro_name ';'
                        | 'Macro' macro_name '{' vec_data '}'
                        | 'GoTo' pat_label ';'
                        | 'Stop' ';'
                        | 'ScanChain' chain_name ';'
                        | 'BreakPoint' ';'
                        | 'BreakPoint' '{' pattern_statements '}'
                        | 'IddqTestPoint' ';'
                        | 'TimeUnit' '\'' time_def '\'' ';'
                        //| include | annotation | udb | (null)
                        ;
waveform_table_stmt     : 'W'|'WaveformTable';
vector_stmt             : 'V' '{' vec_data '}'
                        | 'Vector' '{' vec_data '}'
                        ;
condition_stmt          : 'C' '{' vec_data '}'
                        | 'Condition' '{' vec_data '}'
                        ;
vec_data                : (sigref_expr '=' vec_data_string ';') vec_data
                        | (sigref_expr '{' vec_data_strings '}') vec_data
                        | non_cyclized_data vec_data
                        |//| include | annotation | udb | (null)
                        ;
non_cyclized_data       : '@' time_value event_pair ';'
                        | '@' time_value '{'  event_pair*  '}'
                        ;
time_value              : integer;
event_pair              : sigref_expr '=' event
                        //| include | annotation | udb | (null)
                        ;


vec_data_strings        : (vec_data_string ';')*;


vec_data_string         : wfcs
                        | wfc
                        | '\r' integer wfcs             vec_data_string
                        | hex_mode                      vec_data_string
                        | dec_mode                      vec_data_string
                        | hexchars                      vec_data_string
                        | '\\r' integer hexchars        vec_data_string
                        | wfc_mode                      vec_data_string
                        | dec_mode                      vec_data_string
                        | integer                       vec_data_string
                        | '\\r' integer integer         vec_data_string
                        | wfc_mode                      vec_data_string
                        | hex_mode                      vec_data_string
                        | digit                         vec_data_string
                        ;

hex_mode                : '\\h ' hex_data_string
                        | '\\h'  wfcs hex_data_string
                        ;
wfc_mode                : '\\w'         wfc_data_string;
dec_mode                : ('\\d '|'\\l') dec_data_string    //\l means that a part of the chain length which need to scan.
                        | '\\d'  wfcs   dec_data_string
                        ;


wfc_data_string         : wfcs
                        | wfc
                        | '\r' integer wfcs wfc_data_string
                        | hex_mode  wfc_data_string
                        | dec_mode  wfc_data_string
                        ;

hex_data_string         : hexchars                      hex_data_string
                        | '\\r' integer hexchars        hex_data_string
                        | wfc_mode                      hex_data_string
                        | dec_mode                      hex_data_string
                        |
                        ;

dec_data_string         : integer                       dec_data_string
                        | '\\r' integer integer         dec_data_string
                        | wfc_mode                      dec_data_string
                        | hex_mode                      dec_data_string
                        | digit                         dec_data_string
                        |
                        ;

//vec_data_string         : wfc_data_string
//                        | dec_data_string
//                        | hex_data_string
//                        ;
//
//vec_data_strings        : (vec_data_string ';')*;
//
//
//wfc_data_string         : wfcs
//                        | wfc
//                        | '\r' integer wfcs wfc_data_string
//                        | hex_mode  wfc_data_string
//                        | dec_mode  wfc_data_string
//                        ;
//
//hex_data_string         : hexchars                      hex_data_string
//                        | '\\r' integer hexchars        hex_data_string
//                        | wfc_mode                      hex_data_string
//                        | dec_mode                      hex_data_string
//                        |
//                        ;
//
//dec_data_string         : integer                       dec_data_string
//                        | '\\r' integer integer         dec_data_string
//                        | wfc_mode                      dec_data_string
//                        | hex_mode                      dec_data_string
//                        | digit                         dec_data_string
//                        |
//                        ;


//hex_mode                : '\\h ' hex_data_string
//                        | '\\h'  wfcs hex_data_string
//                        ;
//wfc_mode                : '\\w'         wfc_data_string;
//dec_mode                : ('\\d '|'\\l') dec_data_string    //\l means that a part of the chain length which need to scan.
//                        | '\\d'  wfcs   dec_data_string



hexchars                : WORDS;//need to fix


time_def                : REF_NAME;
//unit                    : ;
pat_name                : name_string;
label                   : name_string ':';

//======================================Timing BLOCK and WaveformTable Block=========================================//
timing                  : 'Timing' timing_name? '{'  timing_list*  '}';
timing_list             : 'WaveformTable' wft '{' wft_list '}'
                        | 'SignalGroups' signal_groups_domain_name ';'
                        | free_running_clock                                    //《IEEE 1450 Std - 2023》
                        //| include | annotation | udb | (null)
                        ;
wft_list                : 'Period' '\'' time_expr '\'' ';'                        wft_list
                        | 'Waveforms' '{' waveforms_list* '}'                     wft_list
                        | 'InheritWaveformTable' (timing_label '.')? wft ';'      wft_list
                        | 'SubWaveforms' '{' subwaveforms_list* '}'               wft_list
                        |  //需要在函数中对重复的部分进行剔除和报错
                        //| include | annotation | udb | (null);
                        ;
waveforms_list          : sigref_expr label?  '{' waveform_item '}';
waveform_item           : 'InheritWaveform' ((timing_label '.')wft '.')cell ';' waveform_item
                        | wfc '{' wfc_def_list '}'                              waveform_item
                        | wfcs '{' wfcs_def_list '}'                            waveform_item
                        //| include | annotation | udb | (null)
                        |
                        ;


subwaveforms_list       : swf_label ':' 'Duration' '\'' time_expr '\'' '{' sub_def_list '}'
                         //| include | annotation | udb | (null);
                        ;

swf_label               : name_string;
timing_label            : name_string;
sub_def_list            :  ('\'' time_expr '\'' events ';')                 sub_def_list
                        | ('\'' time_expr '\'' events '[' integer ']' ';')  sub_def_list
                        | ('\'' time_expr '\'' ';')                         sub_def_list
                        | (events ';')                                      sub_def_list
                        | (events '[' integer ']' ';')                      sub_def_list
                        | (label ':')                                       sub_def_list
                        |
                        //| include | annotation | udb | (null);
                        ;

wfc_def_list            : (label ':')?  ('\'' time_expr '\'' events ';')                                         wfc_def_list
                        | (label ':')?  ('\'' time_expr '\'' ';' )                                               wfc_def_list
                        | (label ':')?  (events ';')                                                             wfc_def_list
                        | (label ':')?  (('\'' time_expr '\'')? (integer)? swf_label ';')                        wfc_def_list
                        | (label ':')?  ('\'' time_expr '\'')? (integer)? swf_label '[' integer ']' ';'          wfc_def_list
                        | (label ':')?  (('\'' time_expr '\'')? (integer)? swf_label '[' '#' ']' ';')            wfc_def_list
                        | 'InheritWaveform' (((timing_label '.')? wft '.')? cell '.')? wfc  ';'                  wfc_def_list
                        |
                        //| include | annotation | udb | (null);
                        ;

wfcs_def_list           : (label ':')? '\'' time_expr '\'' events ';'                                           wfcs_def_list
                        | (label ':')? '\'' time_expr '\'' events '[' integer ']' ';'                           wfcs_def_list
                        | (label ':')? '\'' time_expr '\'' ';'                                                  wfcs_def_list
                        | (label ':')?  events ';'                                                              wfcs_def_list
                        | (label ':')?  events '[' integer ']' ';'                                              wfcs_def_list
                        | (label ':')? ('\'' time_expr '\'')? (integer)? swf_label ';'                          wfcs_def_list
                        | (label ':')? ('\'' time_expr '\'')? (integer)? swf_label '[' integer ']' ';'          wfcs_def_list
                        | (label ':')? ('\'' time_expr '\'')? (integer)? swf_label '[' '#' ']' ';'              wfcs_def_list
                        | 'InheritWaveform' (((timing_label '.')? wft '.')? cell '.')? wfc  ';'                 wfcs_def_list
                        |
                        //| include | annotation | udb | (null);
                        ;
cell                    : name_string;
events                  : events '/' events
                        | event
                        ;
event                   : 'D'|'ForceDown'|'U'|'ForceUp'|'Z'|'ForceOff'|'P'|'ForcePrior'
                        | 'L'|'CompareLow'|'H'|'CompareHigh'
                        | 'x' | 'X' | 'CompareUnknown'
                        | 'T' | 'CompareOff'
                        | 'V' | 'CompareValid'
                        | 'l' | 'CompareLowWindow'
                        | 'h' | 'CompareHighWindow'
                        | 't' | 'CompareOffWindow'
                        | 'v' | 'CompareValidWindow'
                        | 'N' | 'ForceUnknown'
                        | 'A' | 'LogicLow'
                        | 'B' | 'LogicHigh'
                        | 'F' | 'LogicZ'
                        | '?' | 'Unknown'
                        | 'G' | 'ExpectHigh'
                        | 'R' | 'ExpectLow'
                        | 'Q' | 'ExpectOff'
                        | 'M' | 'Marker'
                        ;

time_expr               : time_expr '+' time_expr
                        | time_expr '*' time_expr
                        | time_expr '/' time_expr
                        | time_expr '-' time_expr
                        | '-' time_expr
                        | '@' time_expr
                        | function '('  function_args?  ')'
                        | time_expr '==' time_expr
                        | time_expr '<=' time_expr
                        | time_expr '>=' time_expr
                        | time_expr '<' time_expr
                        | time_expr '>' time_expr
                        | time_expr '!=' time_expr
                        | time_expr '?' time_expr ':' time_expr
                        | name_string time_expr
                        | '(' time_expr ')'
                        | decimal
                        | ref_varname
                        ;

function                : 'min'|'max'|name_string;
function_args           : time_expr ',' function_args
                        | time_expr
                        ;

decimal                 : DECIMAL|FLOAT|WORDS;
//signed_integer          : integer | '-' integer;
//
//decimal                 : signed_integer
//                        | signed_integer '.' integer
//                        | signed_integer 'e' signed_integer
//                        | signed_integer '.' integer 'e' signed_integer
//                        ;

//engineering_units       : engineering_prefix?  engineering_unit
//                        ;
//engineering_prefix      : 'E' | 'P' | 'T' | 'G' | 'M' | 'k' | 'm' | 'u' | 'n' | 'p' | 'f' | 'a';
//engineering_unit        : 'A' | 'Cel' | 'F' | 'H' | 'Hz' | 'm' | 'Ohm' | 's' | 'W' | 'V';

ref_varname             : REF_NAME |'@';

wfc                     : upper_case_letter|lower_case_letter|'#'|'%'|'0'|'1';
wfc_words               : WFC_WORDS | WORDS;                                   //$$$$$$$$$#####rule "wfc_words"#####in the parser need to fix the WORDS only support Letter and Digit.
wfcs                    : wfc_words wfcs
                        | '#' wfcs
                        | '%' wfcs
                        | integer wfcs
                        | upper_case_letter wfcs
                        | lower_case_letter wfcs
                        |;//$$$$$$$$$##########in the parser need to fix the WORDS only support Letter and Digit.
//lexer_wfc_words         : LETTER_OR_DIGIT+;

timing_name             : name_string;
wft                     : name_string;


//file_name       : (SIMPLE_CHARACTER|SPECIAL_CHARACTER)*;
//
name_string             : NAME_STRING | WORDS;
//======================================Other Miscellaneous Statements=========================================//
//identifier              : simple_identifier | escaped_identifier;
//simple_identifier       : letter_or_underline simple_characters;
//letter_or_underline     : letter | underline;
//simple_characters       : letter        simple_characters
//                        | digit         simple_characters
//                        | underline     simple_characters
//                        |
//                        ;
//letter                  : upper_case_letter | lower_case_letter;
upper_case_letter       : 'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'I'|'J'|'K'|'L'
                        | 'M'|'N'|'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'
                        | 'Y'|'Z'
                        ;
lower_case_letter       : 'a'|'b'|'c'|'d'|'e'|'f'|'g'|'h'|'i'|'j'|'k'|'l'
                        | 'm'|'n'|'o'|'p'|'q'|'r'|'s'|'t'|'u'|'v'|'w'|'x'
                        | 'y'|'z'
                        ;
//underline               : '_';
//escaped_identifier      : '"' escaped_characters '"';
//escaped_characters      : letter                escaped_characters
//                        | digit                 escaped_characters
//                        | underline             escaped_characters
//                        | special_character     escaped_characters
//                        //| whitespace_character  escaped_characters
//                        ;
//special_character       :   '!'|'@'|'#'|'$'|'%'|'^'|'&'|'*'|'('|')'|'-'|'+'|'='|'|'|'`'|'~'
//                        |   '{'|'['|'}'|']'|':'|';'|'\''|','|'<'|'.'|'>'|'/'|'?'|'\\';
////whitespace_character    :   ' '|'\t'|'\n';
////string                  : escaped_identifier;
////hexdigit                : digit|'a'|'A'|'b'|'B'|'c'|'C'|'d'|'D'|'e'|'E'|'f'|'F';
digit                   : '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9';
//hexdigits               :  digit     hexdigits
//                        | 'a'        hexdigits
//                        | 'A'        hexdigits
//                        | 'b'        hexdigits
//                        | 'B'        hexdigits
//                        | 'c'        hexdigits
//                        | 'C'        hexdigits
//                        | 'd'        hexdigits
//                        | 'D'        hexdigits
//                        | 'e'        hexdigits
//                        | 'E'        hexdigits
//                        | 'f'        hexdigits
//                        | 'F'        hexdigits
//                        |
//                        ;
//
//integer                 : '0'       integer
//                        | '1'       integer
//                        | '2'       integer
//                        | '3'       integer
//                        | '4'       integer
//                        | '5'       integer
//                        | '6'       integer
//                        | '7'       integer
//                        | '8'       integer
//                        | '9'       integer
//                        ;


//======================================Others=========================================//
//INT                     :   [0-9]+;
//WORDS                   :   [a-zA-Z_]+[a-zA-Z0-9_]+;
//WFC                     :   [a-zA-Z];
LINE_COMMENT : '//' .*? '\r'? '\n' -> skip ;    // 匹配"//" stuff '\n'
COMMENT      : '/*' .*? '*/'       -> skip ;    // 匹配"/*" stuff "*/"
//STRING  : '"' .*? '"';
ANN_TEXT        : '{*' .*? '*}';
WS :  [ \t\r\n]+ -> skip;

